package com.example.zyh.controller;


import com.example.zyh.pojo.Shop;
import com.example.zyh.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@ResponseBody
@RequestMapping("/Shop")
public class ShopController {
    @Autowired
    private ShopService shopService;
    @RequestMapping("/list")
    public List<Shop> select(){
        return shopService.select();
    }
    @RequestMapping("/add")
    public void add(Shop shop){
        shopService.addShop(shop);
    }
    @RequestMapping("/delete")
    public void delete(int id){
        shopService.deleteShop(id);
    }
    @RequestMapping("/update")
    public void update(Shop shop){
        shopService.updateShop(shop);
    }
    @RequestMapping("/selectlike")
    public List<Shop> selectlike(Shop shop){
        if (shop.getName()==null){
            shop.setName("");
        }
        if (shop.getUsername()==null){
            shop.setUsername("");
        }
        if (shop.getSex()==null){
            shop.setSex("");
        }
        if (shop.getArea()==null){
            shop.setArea("");
        }
        if (shop.getStyle()==null){
            shop.setStyle("");
        }

        return shopService.selectlike(shop);
    }

}
